"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const MySQLService_1 = __importDefault(require("./service/MySQLService"));
class Dao {
    /** 将玩家登录状态归0 */
    initUserLoginState() {
        var sql = 'update user set is_logining = ?';
        let datas = [0];
        // 执行sql，并处理执行的结果
        MySQLService_1.default.connection.query(sql, datas, function (err, result) {
            if (err) {
                console.log('初始化失败： ', err.message);
                return;
            }
            console.log('初始化成功，受影响的行数：', result.affectedRows);
        });
    }
    /** 查询用户 */
    selectByUsername(username, callback) {
        MySQLService_1.default.connection.query('select * from user where username = ? limit 1', [username], function (err, result) {
            callback(result);
        });
    }
    /** 注册用户 */
    insertUser(username, password) {
        let sql = "insert into user values( ? , ? , 100 , 0 , 0 , 0 )";
        let datas = [username, password];
        MySQLService_1.default.connection.query(sql, datas, function (err, result) {
            if (err) {
                console.log('插入失败', err.message);
                return;
            }
            console.log('注册成功：' + username);
        });
    }
    checkGetDate(sql_resluts) {
        if (sql_resluts != null) {
            return false;
        }
        return true;
    }
}
exports.default = new Dao();
